package com.captain.special.二叉树.简单;

import com.captain.leetcode.TreeNode;

/**
 * Des:
 * 二叉树的深度为根节点到最远叶子节点的最长路径上的节点数
 *
 * @author XL
 * @Date 2022/5/6 16:24
 */
public class 二叉树的最大深度104 {
    public int maxDepth(TreeNode root) {
        return recur(root);
    }

    public int recur(TreeNode node) {
        if (node == null) {
            return 0;
        }
        int left = recur(node.left);
        int right = recur(node.right);
        return Math.max(left, right) + 1;
    }
}
